Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jbox2d.dynamics
Class Body

    java.lang.Object
      org.jbox2d.dynamics.Body

    public class Body

extends java.lang.Object

Field Summary
`static int` | `e_allowSleepFlag`
`static int` | `e_bulletFlag`
`static int` | `e_dynamicType`
`static int` | `e_fixedRotationFlag`
`static int` | `e_frozenFlag`
`static int` | `e_islandFlag`
`static int` | `e_maxTypes`
`static int` | `e_sleepFlag`
`static int` | `e_staticType`
`float` | `m_angularDamping`
`float` | `m_angularVelocity`
`ContactEdge` | `m_contactList`
`int` | `m_flags`
`Vec2` | `m_force`
`float` | `m_I`
`float` | `m_invI`
`float` | `m_invMass`
`JointEdge` | `m_jointList`
`float` | `m_linearDamping`
`Vec2` | `m_linearVelocity`
`float` | `m_mass`
`Body` | `m_next`
`Body` | `m_prev`
`int` | `m_shapeCount`
`Shape` | `m_shapeList`
`float` | `m_sleepTime`
`Sweep` | `m_sweep` The swept motion for CCD
`float` | `m_torque`
`int` | `m_type`
`java.lang.Object` | `m_userData` A holder to attach external data to a body.
`World` | `m_world`
`XForm` | `m_xf` The body origin transform

Constructor Summary
`Body(BodyDef bd, int type, World world)` Should not be called by user, as it will not be properly added to the world.

Method Summary
`void` | `advance(float t)` For internal use only.
`void` | `allowSleeping(boolean flag)` Set to false to prevent this body from sleeping due to inactivity.
`void` | `applyForce(Vec2 force, Vec2 point)` Apply a force at a world point.
`void` | `applyImpulse(Vec2 impulse, Vec2 point)` Apply an impulse at a point.
`void` | `applyTorque(float torque)` Apply a torque.
`void` | `computeMass()` For internal use only.
`Shape` | `createShape(ShapeDef def)` Creates a shape and attach it to this body.
`void` | `destroyShape(Shape s)` Destroy a shape.
`float` | `getAngle()` Get the angle in radians.
`float` | `getAngularVelocity()` Get the angular velocity.
`ContactEdge` | `getContactList()` Get the linked list of all contacts attached to this body.
`float` | `getInertia()` Get the central rotational inertia of the body.
`JointEdge` | `getJointList()` Get the linked list of all joints attached to this body.
`Vec2` | `getLinearVelocity()` Get a copy of the linear velocity of the center of mass.
`Vec2` | `getLocalCenter()` Get a copy of the local position of the center of mass.
`Vec2` | `getLocalPoint(Vec2 worldPoint)` Gets a local point relative to the body's origin given a world point.
`Vec2` | `getLocalVector(Vec2 worldVector)` Gets a local vector given a world vector.
`float` | `getMass()` Get the total mass of the body.
`Body` | `getNext()` Get the next body in the world's body list.
`Vec2` | `getPosition()` Get a copy of the world body origin position.
`Shape` | `getShapeList()` Get the linked list of all shapes attached to this body.
`java.lang.Object` | `getUserData()` Get the user data Object reference that was provided in the body definition.
`Vec2` | `getWorldCenter()` Get a copy of the world position of the center of mass.
`Vec2` | `getWorldPoint(Vec2 localPoint)` Get the world coordinates of a point given the local coordinates.
`Vec2` | `getWorldVector(Vec2 localVector)` Get the world coordinates of a vector given the local coordinates.
`XForm` | `getXForm()` Get a copy of the body transform for the body's origin.
`boolean` | `isBullet()` Is this body treated like a bullet for continuous collision detection?
`boolean` | `isConnected(Body other)` This is used to prevent connected bodies from colliding.
`boolean` | `isDynamic()` Is this body dynamic (movable)?
`boolean` | `isFrozen()` Is this body frozen?
`boolean` | `isSleeping()` Is this body sleeping (not simulating).
`boolean` | `isStatic()` Is this body static (immovable)?
`void` | `setAngularVelocity(float omega)` Set the angular velocity.
`void` | `setBullet(boolean flag)` Should this body be treated like a bullet for continuous collision detection? Use sparingly, as continuous collision detection can be expensive.
`void` | `setLinearVelocity(Vec2 v)` Set the linear velocity of the center of mass.
`void` | `setMass(MassData massData)` Set the mass properties.
`void` | `setMassFromShapes()` Compute the mass properties from the attached shapes.
`boolean` | `setXForm(Vec2 position, float angle)` Set the position of the body's origin and rotation (radians).
`boolean` | `synchronizeShapes()` For internal use only.
`void` | `synchronizeTransform()` For internal use only.
`void` | `wakeUp()` Wake up this body so it will begin simulating.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### e_frozenFlag

    public static final int e_frozenFlag

See Also:
  Constant Field Values

### e_islandFlag

    public static final int e_islandFlag

See Also:
  Constant Field Values

### e_sleepFlag

    public static final int e_sleepFlag

See Also:
  Constant Field Values

### e_allowSleepFlag

    public static final int e_allowSleepFlag

See Also:
  Constant Field Values

### e_bulletFlag

    public static final int e_bulletFlag

See Also:
  Constant Field Values

### e_fixedRotationFlag

    public static final int e_fixedRotationFlag

See Also:
  Constant Field Values

### m_flags

    public int m_flags

### e_staticType

    public static final int e_staticType

See Also:
  Constant Field Values

### e_dynamicType

    public static final int e_dynamicType

See Also:
  Constant Field Values

### e_maxTypes

    public static final int e_maxTypes

See Also:
  Constant Field Values

### m_type

    public int m_type

### m_xf

    public XForm m_xf

  The body origin transform

### m_sweep

    public Sweep m_sweep

  The swept motion for CCD

### m_linearVelocity

    public Vec2 m_linearVelocity

### m_angularVelocity

    public float m_angularVelocity

### m_force

    public Vec2 m_force

### m_torque

    public float m_torque

### m_world

    public World m_world

### m_prev

    public Body m_prev

### m_next

    public Body m_next

### m_shapeList

    public Shape m_shapeList

### m_shapeCount

    public int m_shapeCount

### m_jointList

    public JointEdge m_jointList

### m_contactList

    public ContactEdge m_contactList

### m_mass

    public float m_mass

### m_invMass

    public float m_invMass

### m_I

    public float m_I

### m_invI

    public float m_invI

### m_linearDamping

    public float m_linearDamping

### m_angularDamping

    public float m_angularDamping

### m_sleepTime

    public float m_sleepTime

### m_userData

    public java.lang.Object m_userData

  A holder to attach external data to a body. Useful to keep track of what game entity each body represents. This is copied from the BodyDef used to create the body, so may be set there instead.

Constructor Detail

### Body

    public Body(BodyDef bd,
                int type,
                World world)

  Should not be called by user, as it will not be properly added to the world. Instead, create a BodyDef object and pass it to World.createDynamicBody or World.createStaticBody.

  Parameters:
    `bd` - Body definition
    `type` - Body.e_dynamicType or Body.e_staticType
    `world` - World to create body in

Method Detail

### createShape

    public Shape createShape(ShapeDef def)

  Creates a shape and attach it to this body.
  Warning: This function is locked during callbacks.

  Parameters:
    `def` - the shape definition.

### destroyShape

    public void destroyShape(Shape s)

  Destroy a shape. This removes the shape from the broad-phase and therefore destroys any contacts associated with this shape. All shapes attached to a body are implicitly destroyed when the body is destroyed.
  Warning: This function is locked during callbacks.

  Parameters:
    `s` - the shape to be removed.

### setMass

    public void setMass(MassData massData)

  Set the mass properties. Note that this changes the center of mass position. If you are not sure how to compute mass properties, use setMassFromShapes(). The inertia tensor is assumed to be relative to the center of mass.

  Parameters:
    `massData` - the mass properties.

### setMassFromShapes

    public void setMassFromShapes()

  Compute the mass properties from the attached shapes. You typically call this after adding all the shapes. If you add or remove shapes later, you may want to call this again. Note that this changes the center of mass position.

### setXForm

    public boolean setXForm(Vec2 position,
                            float angle)

  Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies.

  Parameters:
    `position` - the new world position of the body's origin (not necessarily the center of mass).
    `angle` - the new world rotation angle of the body in radians.
  Returns:
    false if the movement put a shape outside the world. In this case the body is automatically frozen.

### getXForm

    public XForm getXForm()

  Get a copy of the body transform for the body's origin.

  Returns:
    the world transform of the body's origin.

### getPosition

    public Vec2 getPosition()

  Get a copy of the world body origin position. This is not necessarily the same as the center of mass.

  Returns:
    the world position of the body's origin.

### getAngle

    public float getAngle()

  Get the angle in radians.

  Returns:
    the current world rotation angle in radians.

### getWorldCenter

    public Vec2 getWorldCenter()

  Get a copy of the world position of the center of mass.

### getLocalCenter

    public Vec2 getLocalCenter()

  Get a copy of the local position of the center of mass.

### setLinearVelocity

    public void setLinearVelocity(Vec2 v)

  Set the linear velocity of the center of mass.

  Parameters:
    `v` - the new linear velocity of the center of mass.

### getLinearVelocity

    public Vec2 getLinearVelocity()

  Get a copy of the linear velocity of the center of mass.

  Returns:
    the linear velocity of the center of mass.

### setAngularVelocity

    public void setAngularVelocity(float omega)

  Set the angular velocity.

  Parameters:
    `omega` - the new angular velocity in radians/second.

### getAngularVelocity

    public float getAngularVelocity()

  Get the angular velocity.

  Returns:
    the angular velocity in radians/second.

### applyForce

    public void applyForce(Vec2 force,
                           Vec2 point)

  Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.

  Parameters:
    `force` - the world force vector, usually in Newtons (N).
    `point` - the world position of the point of application.

### applyTorque

    public void applyTorque(float torque)

  Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.

  Parameters:
    `torque` - about the z-axis (out of the screen), usually in N-m.

### applyImpulse

    public void applyImpulse(Vec2 impulse,
                             Vec2 point)

  Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.

  Parameters:
    `impulse` - the world impulse vector, usually in N-seconds or kg-m/s.
    `point` - the world position of the point of application.

### getMass

    public float getMass()

  Get the total mass of the body.

  Returns:
    the mass, usually in kilograms (kg).

### getInertia

    public float getInertia()

  Get the central rotational inertia of the body.

  Returns:
    the rotational inertia, usually in kg-m^2.

### getWorldPoint

    public Vec2 getWorldPoint(Vec2 localPoint)

  Get the world coordinates of a point given the local coordinates.

  Parameters:
    `localPoint` - a point on the body measured relative the the body's origin.
  Returns:
    the same point expressed in world coordinates.

### getWorldVector

    public Vec2 getWorldVector(Vec2 localVector)

  Get the world coordinates of a vector given the local coordinates.

  Parameters:
    `localVector` - a vector fixed in the body.
  Returns:
    the same vector expressed in world coordinates.

### getLocalPoint

    public Vec2 getLocalPoint(Vec2 worldPoint)

  Gets a local point relative to the body's origin given a world point.

  Parameters:
    `worldPoint` - a point in world coordinates.
  Returns:
    the corresponding local point relative to the body's origin.

### getLocalVector

    public Vec2 getLocalVector(Vec2 worldVector)

  Gets a local vector given a world vector.

  Parameters:
    `worldVector` - a vector in world coordinates.
  Returns:
    the corresponding local vector.

### isBullet

    public boolean isBullet()

  Is this body treated like a bullet for continuous collision detection?

### setBullet

    public void setBullet(boolean flag)

  Should this body be treated like a bullet for continuous collision detection? Use sparingly, as continuous collision detection can be expensive.

### isStatic

    public boolean isStatic()

  Is this body static (immovable)?

### isDynamic

    public boolean isDynamic()

  Is this body dynamic (movable)?

### isFrozen

    public boolean isFrozen()

  Is this body frozen?

### isSleeping

    public boolean isSleeping()

  Is this body sleeping (not simulating).

### allowSleeping

    public void allowSleeping(boolean flag)

  Set to false to prevent this body from sleeping due to inactivity.

### wakeUp

    public void wakeUp()

  Wake up this body so it will begin simulating.

### getShapeList

    public Shape getShapeList()

  Get the linked list of all shapes attached to this body.

  Returns:
    first Shape in linked list

### getJointList

    public JointEdge getJointList()

  Get the linked list of all joints attached to this body.

  Returns:
    first JointEdge in linked list

### getContactList

    public ContactEdge getContactList()

  Get the linked list of all contacts attached to this body.

  Returns:
    first ContactEdge in linked list

### getNext

    public Body getNext()

  Get the next body in the world's body list.

### getUserData

    public java.lang.Object getUserData()

  Get the user data Object reference that was provided in the body definition.

### computeMass

    public void computeMass()

  For internal use only.

### synchronizeShapes

    public boolean synchronizeShapes()

  For internal use only.

### synchronizeTransform

    public void synchronizeTransform()

  For internal use only.

### isConnected

    public boolean isConnected(Body other)

  This is used to prevent connected bodies from colliding. It may lie, depending on the collideConnected flag, so it won't be very useful external to the engine.

### advance

    public void advance(float t)

  For internal use only.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD